﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model.Admin;
  
 

namespace Xproject.Util
{
   public class Cache_SystemInfo
    {              
        public static string CACHE_KEY_ADMIN_MENU = "CACHE_KEY_ADMIN_MENU";
        public static string CACHE_KEY_ADMIN_ROLE = "CACHE_KEY_ADMIN_ROLE";
        
        public static List<AdminMenu> AdminMenus {
            get {                 
               return  System.Web.HttpRuntime.Cache[CACHE_KEY_ADMIN_MENU] as List<AdminMenu>;    
                
            }
            set {
                System.Web.HttpRuntime.Cache.Insert(CACHE_KEY_ADMIN_MENU, value, null, DateTime.Now.AddMonths(1), System.Web.Caching.Cache.NoSlidingExpiration);              
            }
        }
        public static List<AdminRole> AdminRoles
        {
            get
            {
                return System.Web.HttpRuntime.Cache[CACHE_KEY_ADMIN_ROLE] as List<AdminRole>;

            }
            set
            {
                System.Web.HttpRuntime.Cache.Insert(CACHE_KEY_ADMIN_ROLE, value, null, DateTime.Now.AddMonths(1), System.Web.Caching.Cache.NoSlidingExpiration);
            }
        }
        public static void ClearRoles()
        {
            System.Web.HttpRuntime.Cache.Remove(CACHE_KEY_ADMIN_ROLE);
        }
        public static void ClearMenus()
        {
            System.Web.HttpRuntime.Cache.Remove(CACHE_KEY_ADMIN_MENU);
        }
    }
}
